package com.dora.pattern.chain;

import lombok.Setter;

/**
 * 抽象记录器
 *
 * @author hanchen
 * @date 2024/03/14
 */
public abstract class AbstractLogger {

   public static int INFO = 1;
   public static int DEBUG = 2;
   public static int ERROR = 3;

   protected int level;

   @Setter
   protected AbstractLogger nextLogger;

   public void logMessage(int level, String message){
      if(this.level <= level){
         write(message);
      }
      if(nextLogger !=null){
         nextLogger.logMessage(level, message);
      }
   }

   /**
    * 写方法
    *
    * @param message 消息
    */
   abstract protected void write(String message);

}
